/**
 * s = "abcde", words = ["a","bb","acd","ace"]
 * 匹配子串
 * @param {string} s
 * @param {string[]} words
 * @return {number}
 */
var numMatchingSubseq = function (s, words) {
    let ans = 0;
    for (let word of words) {
        let i = 0, j = 0;
        
        while (i < s.length && j < word.length) {
            if (s[i] === word[j]) {
                j++;
            }
            i++;
        }

        // j和word长度相等说明匹配到了最后
        if (j === word.length) {
            ans++;
        }
    }
    return ans
};

